package state;/** * Created by Administrator on 2018-11-2. */public class SoldState implements State {    NewGumBallMachine newGumBallMachine;    public  SoldState(NewGumBallMachine newGumBallMachine){        this.newGumBallMachine = newGumBallMachine;    }    public void insertQuarter() {        System.out.println("Please wait! we're already giving you a gumball");    }    public void ejectQuarter() {        System.out.println("Sorry,you already turned the crank");    }    public void trunCrank() {        System.out.println("Turning twice doesn't get you another gumball");    }    public void dispense() {         newGumBallMachine.releaseBall();         if(newGumBallMachine.getCount()>0){             newGumBallMachine.setState(newGumBallMachine.getNoQuarterState());         }else{             System.out.println("Oops, out of gumballs");             newGumBallMachine.setState(newGumBallMachine.getSoldOutState());         }    }}